package cn.stylefeng.guns.modular.system.repository;

import cn.stylefeng.guns.modular.system.model.DeviceRecord;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface DeviceRecordRepository extends MongoRepository<DeviceRecord, String> {
    List<DeviceRecord> findAllByDeviceid(String deviceid);

    List<DeviceRecord> findAllByAction(String action);

    List<DeviceRecord> findAllByDate(Long date);

    List<DeviceRecord> findAllByDeviceidAndAction(String deviceid, String action);

    List<DeviceRecord> findAllByDeviceidAndDate(String deviceid, Long date);

    List<DeviceRecord> findAllByDateAndAction(Long date, String action);

    List<DeviceRecord> findAllByDeviceidAndActionAndDate(String deviceid, String action, Long date);
    Page<DeviceRecord> findAllByDeviceidAndDateBetween(String deviceid, Long startTime,Long endTime,Pageable pageable);

    Page<DeviceRecord> findAllByActionAndDateBetween(String action, Long startTime,Long endTime,Pageable pageable);

    Page<DeviceRecord> findAllByDate(Long date, Pageable pageable);

    Page<DeviceRecord> findAllByDeviceidAndActionAndDateBetween(String deviceid, String action,Long startTime,Long endTime, Pageable pageable);

    Page<DeviceRecord> findAllByDeviceidAndActionAndDate(String deviceid, String action, Long date,Pageable pageable);


    Page<DeviceRecord> findAllByDateBetween(Long startDate,Long endDate,Pageable pageable);
}
